<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <style>
        body {
            background-color: black;
            }
    </style>
    <button>开灯</button>
    <script>
        const button = document.querySelector('button');
        let isOn = false;
        button.addEventListener('click', () => {
                if (isOn) {
                document.body.style.backgroundColor = 'black';
                button.innerText = '开灯';
                isOn = false;
                    } else {
                            document.body.style.backgroundColor = 'white';
                            button.innerText = '关灯';
                            isOn = true;
                    }
                        });
    </script>
</body>
</html>